# -*-  coding:utf-8   -*-
import requests
import unittest
from public  import  public as  p
class   case_01_Admin(unittest.TestCase):

    @classmethod
    def  setUpClass(cls) -> None:
        cls.token = p.getToken()#至执行一次

    #测试用例前执行每次都执行     前置测试用例  登录
    def  setUp(self) -> None:
        self.headers = {
            'Access-Token' : self.token
        }

    #编写测试用例
    '''新增管理员列表'''
    def test_01_new_admin_list(self):
        #路径
        url = 'http://127.0.0.1/index.php?s=/store/store.user/add'
        real_name = '接口测试_' + p.getTime()
        user_name = 'jkcs' + p.getTime()
        data = {"form":{"real_name": real_name,"user_name":  user_name,"roles":[10001],"password":"123456","password_confirm":"123456","sort":100}}
        header = self.headers
        header['Content-Length'] = '129'
        header['Content-Type'] = 'application/json;charset=UTF-8'
        header['Host'] = '127.0.0.1'
        res = requests.post(url=url,json=data,headers=header)
        #开始断言
        yu = '添加成功'
        shi = res.text
        self.assertIn(yu,shi,'正向数据会员添加成功')


